<%' Declaring variables
Dim titulo, autor, editorial, detalle, ISBN, precio, Conn, sql_insert

' A Function to check if some field entered by user is empty
Function ChkString(string)
	If string = "" Then string = " "
	ChkString = Replace(string, "'", "''")
End Function

' Receiving values from Form
titulo = ChkString(Request.Form("titulo"))
autor = ChkString(Request.Form("autor"))
editorial = ChkString(Request.Form("editorial"))
detalle = ChkString(Request.Form("detalle"))
ISBN = ChkString(Request.Form("ISBN"))
precio = ChkString(Request.Form("precio"))

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={MySQL ODBC 5.1 Driver}; Server=localhost; Port=3306; Database=redes; UID=root; PWD="
sql_insert= "insert into libros (Titulo, Autor, Editorial, Detalle, ISBN, Precio) values ("""&titulo&""","""&autor&""","""&editorial&""","""&detalle&""","""&ISBN&""","""&precio&""")"

Conn.Execute sql_insert
Conn.Close

Response.Redirect "listBooks.asp"


%>